package com.apexedu.portal.controller;

import com.apexedu.framework.util.DBUtil;
import com.apexedu.identity.IdConstants;
import com.apexedu.identity.entity.TSysUser;
import com.apexedu.portal.constant.ActionConstant;
import com.apexedu.portal.constant.Constants;
import com.apexedu.portal.entity.Lbxx;
import com.apexedu.portal.entity.TCity;
import com.apexedu.portal.util.DBMUtil;
import com.apexedu.portal.util.LittleTimer;
import com.apexedu.util.json.JsonUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;

/**
 * 门户4.0展示界面 青海
 * Created by ly on 2015/3/5.
 */
@Controller
public class MhQhjgxyController extends BaseController {

    private static final String[] weeks = new String[]{"周日", "周一", "周二", "周三", "周四", "周五", "周六"};

    /**
     * 初始界面
     *
     * @return 初始界面
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_init, method = RequestMethod.GET)
    public String init(HttpServletRequest request) {
        debug("<<{}>> init start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            String type = getUsertype(request); //获取用户类型
            getWeather(request); //获取天气信息
            initTzgg(request, type); //初始化通知公告
            if (Constants.MhUserType.LS.equals(type)) { //教职工站点
                setZztx(request);//设置着装提醒
            }
            initDyfw(request, type); //初始化订阅服务
            return ActionConstant.MhQh.Forward_init;
        } catch (Exception e) {
            error("<<{}>> init error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> init end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 设置着装提醒
     *
     * @param request
     */
    private void setZztx(HttpServletRequest request) {
        LittleTimer timer = new LittleTimer(); // 计时器
        try {
            DBMUtil dbutil = new DBMUtil("hr");
            String sql = "select substr(substr(tp,instr(tp,'Image')+6,100),0,instr(substr(tp,instr(tp,'Image')+6,100),'\"')-1) from hr_t_zztx where zzsd=?";
            // 今日着装
            Object today = dbutil.queryFieldValue(sql, "1");
            /*Clob clob = (Clob) today;// java.sql.Clob类型
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    clob.getAsciiStream()));
            String todayStr = reader.readLine();*/
            request.setAttribute("today", today);

            // 明日着装
            Object tom = dbutil.queryFieldValue(sql, "2");
            /*clob = (Clob) tom;// java.sql.Clob类型
            reader = new BufferedReader(new InputStreamReader(
                    clob.getAsciiStream()));
            String tomStr = reader.readLine();*/
            request.setAttribute("tom", tom);
        } catch (Exception e) {
            error("<<{}>> setZztx error : {}", this.getClass().getSimpleName(),
                    e); // 日志
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> setZztx end : {}", this.getClass().getSimpleName(),
                    timer.end());// 计算方法执行时间
        }
    }

    /**
     * 初始化服务资源
     *
     * @param request --
     */
    private void initDyfw(HttpServletRequest request, String type) {
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        String mrfwid = "mrfw";
        String dyfwid = "dyfw";
        if (Constants.MhUserType.XS.equals(type)) { //学生站点
            mrfwid = "mrfwxs";
            dyfwid = "dyfwxs";
        }
        request.setAttribute("mrfw", getDyfwList(user.getUserloginid(), mrfwid));
        request.setAttribute("dyfw", getDyfwList(user.getUserloginid(), dyfwid));
        request.setAttribute("mrfwid", mrfwid);
        request.setAttribute("dyfwid", dyfwid);
        request.setAttribute("userid", user.getUserloginid());
    }

    /**
     * 获取服务集合json
     *
     * @param request
     * @return
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_getServer, method = RequestMethod.GET)
    @ResponseBody
    public String getServerJson(HttpServletRequest request) {
        debug("<<{}>> getServerJson start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            String userloginid = user.getUserloginid();
            StringBuffer sb = new StringBuffer("{\"bgsw\":");
            sb.append(JsonUtil.getJSONString(getDyfwList(userloginid, "bgsw")));
            sb.append(",\"xxfw\":");
            String type = (String) request.getSession().getAttribute("type");
            if (Constants.MhUserType.XS.equals(type)) { //学生站点
                sb.append(JsonUtil.getJSONString(getDyfwList(userloginid, "xxfwxs")));
            } else {
                sb.append(JsonUtil.getJSONString(getDyfwList(userloginid, "xxfw")));
            }
            sb.append("}");
            return sb.toString();
        } catch (Exception e) {
            error("<<{}>> getServerJson error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> getServerJson end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 初始化通知公告
     *
     * @param request
     */
    private void initTzgg(HttpServletRequest request, String type) throws Exception {
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        DBMUtil dbmUtil = new DBMUtil("oa");
        List<Lbxx> yntz = getTzgg(dbmUtil, "2", null);
        request.setAttribute("yntz", yntz); //院内通知条数
        int yntzys = yntz.size() % 5 == 0 ? yntz.size() / 5 : (yntz.size() / 5 + 1);
        request.setAttribute("yntzys", yntzys == 0 ? 1 : yntzys);//院内通知页数
        if (Constants.MhUserType.LS.equals(type)) { //教职工站点
            request.setAttribute("zlhdb", getTzgg(dbmUtil, null,
                    "select b.tybsf as id,b.xn||b.zc||'周列会督办' as title,to_date(b.fbrq,'yyyy-MM-dd') as time" +
                            " from (select id,fbrq,zc,xn,tybsf,rownum as rm" +
                            " from (select a.ID,a.fbrq,b.mc as zc ,xq.xqmc as xn,a.tybsf from OA_ZLHDB a" +
                            " left join t_zc b on a.zc=b.id left join t_xq xq on xq.id=b.xq" +
                            " where a.publicstatus=1 ORDER BY fbrq DESC))b where 1=1"));
            request.setAttribute("zxfw", getTzgg(dbmUtil, null,
                    "select b.ftitle as title,b.fprocessdate as time, b.tybsf as id from oa_senddocument_njci b" +
                            " where b.fprocessstatus=4 order by b.fprocessdate desc"));
        }
        List<Lbxx> dbsy = getWorkflowNoFrame(user.getUserloginid());
        request.setAttribute("dbsy", dbsy); //待办事宜
        request.setAttribute("dbts", dbsy.size()); //待办条数
        Calendar cal = Calendar.getInstance();
        String week = weeks[cal.get(Calendar.DAY_OF_WEEK) - 1];
        request.setAttribute("weekday", week); //周几
        request.setAttribute("year", cal.get(Calendar.YEAR));
        request.setAttribute("month", cal.get(Calendar.MONTH) + 1);
        request.setAttribute("date", cal.get(Calendar.DAY_OF_MONTH));

        String zc = (String) new DBMUtil("oa").queryFieldValue("select to_char(zbh) from t_zc where to_date(to_char(sysdate,'yyyyMMdd'),'yyyy-MM-dd') between ksrq and jsrq");
        request.setAttribute("zc", zc);
    }

    /**
     * 获取天气信息
     *
     * @param request
     */
    private void getWeather(HttpServletRequest request) {
        TCity city = DBUtil.queryBean("select * from t_city", TCity.class);
        request.setAttribute("city", city);
        if (new Date().getTime() - city.getUpdatetime().getTime() > 1000 * 60 * 60) {
            request.setAttribute("isUpdate", "true"); //是否更新，一小时更新一次
        }
    }

    /**
     * 获取天气信息
     *
     * @return
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_getWeather, method = RequestMethod.GET)
    @ResponseBody
    public String getWeather() {
        LittleTimer timer = new LittleTimer(); // 计时器
        HttpURLConnection connection = null;
        InputStream inputStream = null;
        Reader reader = null;
        BufferedReader bufferedReader = null;
        try {
            String weatherUrl = "http://api.map.baidu.com/telematics/v3/weather?location=%E8%A5%BF%E5%AE%81&output=json&ak=1b7de2623d97e81ce2fe8e1d17967503";
            URL url = new URL(weatherUrl);
            connection = (HttpURLConnection) url.openConnection();
            connection.connect();
            inputStream = connection.getInputStream();

            reader = new InputStreamReader(inputStream, "UTF-8");
            bufferedReader = new BufferedReader(reader);
            String resultData = bufferedReader.readLine();
            return resultData;
        } catch (Exception e) {
            error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
            throw new RuntimeException(e);
        } finally {
            if (null != bufferedReader) {
                try {
                    bufferedReader.close();
                } catch (Exception e) {
                    error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
                }
            }
            if (null != reader) {
                try {
                    reader.close();
                } catch (Exception e) {
                    error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
                }
            }
            if (null != inputStream) {
                try {
                    inputStream.close();
                } catch (Exception e) {
                    error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
                }
            }
            if (null != connection) {
                try {
                    connection.disconnect();
                } catch (Exception e) {
                    error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
                }
            }
            debug("<<{}>> getWeather end : {}", this.getClass().getSimpleName(), timer.end());// 计算方法执行时间
        }
    }

    /**
     * 保存天气信息
     *
     * @param request
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_saveWeather, method = RequestMethod.POST)
    @ResponseBody
    public void saveWeather(HttpServletRequest request) {
        debug("<<{}>> saveWeather start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            String temp = request.getParameter("temp");
            String weather = request.getParameter("weather");
            String tp = request.getParameter("tp");
            String temp1 = temp.split("~")[0].replaceAll(" ", "");
            String temp2 = temp.split("~")[1].replaceAll(" ", "").replaceAll("℃", "");
            DBUtil.executeSQL("update t_city set temp1=?,temp2=?,weather=?,tp=?,updatetime=sysdate", temp1, temp2, weather, tp);
        } catch (Exception e) {
            error("<<{}>> saveWeather error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> saveWeather end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 周会议
     *
     * @return 周会议html代码
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_getZhy, method = RequestMethod.GET)
    @ResponseBody
    public String getZhy() {
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbutil = new DBMUtil("oa");
            /**
             * 查询OA数据库
             * t_zc 表
             * @参数 mc 名称
             * */
            String str = (String) dbutil.queryFieldValue("select zc.mc from t_zc zc where to_date(to_char(sysdate,'yyyyMMdd'),'yyyy-MM-dd') between ksrq and jsrq");
            String mc = str != null ? str : null;
            if (mc == null) {
//                throw new RuntimeException("一周会议无法获取周次名称!");
            }
            debug("<<{}>> doView : zc : {}", this.getClass().getSimpleName(), mc);

            String sql = "select (select decode( to_char(min(gg.kssj),'D'),1,7,to_char(min(gg.kssj),'D')-1) from dual)week ,  " +
                    "'<span><strong>会议内容：</strong>' || ap.hynr ||  '</span><br><span><strong>会议室：</strong>'  " +
                    "|| (select wm_concat(hys.hytmc) from OA_T_HWGL_HYSGL hys " +
                    " where hys.id in (select hysap.ncyhys  from OA_T_HWGL_HYAPB_HYSSYSJ hysap where hysap.oa_t_hwgl_hyapb_id = ap.id)) " +
                    " || '</span><br><span><strong>责任部门：</strong>' ||  " +
                    "(select wm_concat(b.NAME) from lborganization b where b.ID in (select * from table(split(ap.zbdw, ';'))))  ||  " +
                    " '</span><br><span><strong>活动召集人：</strong>' || (select u.NAME from tuser u where u.id = ap.sqr) " +
                    " || '</span><br><span><strong>时间：</strong>' ||  (select to_char(gg.kssj, 'hh24:mi:ss') || '-' " +
                    "|| to_char(gg.jssj, 'hh24:mi:ss') from dual)  || '</span><br><span><strong>参加领导：</strong>' " +
                    "|| (select wm_concat(uu.NAME)  from tuser uu where instr(';'||ap.chld||';', ';'||uu.id||';') > 0) " +
                    " || '</span><br><span><strong>参加人员：</strong>' || " +
                    " (select wm_concat(uu.NAME) from tuser uu where instr(';'||ap.yhry||';', ';'||uu.id||';') > 0) " +
                    " || '</span><br><span><strong>与会角色：</strong>' || " +
                    " (select wm_concat(qq.NAME)  from lbrole qq where instr(';'||ap.yhjs||';', ';'||qq.id||';') > 0) " +
                    " || '</span><br><span><strong>与会部门：</strong>' || " +
                    " (select wm_concat(vv.NAME) from lborganization vv where instr(';'||ap.yhbm||';', ';'||vv.id||';') > 0) " +
                    " || '</span><br><span><strong>校外来宾：</strong>' || ap.xwlb || '</span>' as nr  from OA_T_HWGL_HYAPB ap " +
                    " left join t_zc zc  on zc.id = ap.zc left join OA_T_HWGL_HYAPB_HYSSYSJ gg on ap.id=gg.oa_t_hwgl_hyapb_id" +
                    " where to_date(to_char(sysdate, 'yyyyMMdd'), 'yyyyMMdd')  between zc.ksrq and  zc.jsrq group by" +
                    " (gg.kssj,ap.hynr,ap.zbdw, ap.sqr,gg.jssj,ap.chld,ap.yhry,ap.xwlb,ap.id,ap.sqrq,ap.yhjs,ap.yhbm ) order by ap.sqrq, ap.id ";

            List<Map<String, Object>> list = dbutil.queryForList(null, sql);
            StringBuffer sb = new StringBuffer("");
            for (int i = 0; i < 12; i++) {
                sb.append("<tr>");
                for (int j = 1; j <= 7; j++) {
                    sb.append("<td>");
                    for (Map<String, Object> map : list) {
                        if (j == Integer.parseInt(map.get("week").toString())) {
                            debug("<<{}>> doView : week : {}", this.getClass().getSimpleName(), map.get("week"));
                            sb.append("<div  titleDesc=\"" + map.get("nr") + "\"style=color:white;>※</div>");
                            debug("<<{}>> doView : nr : {}", this.getClass().getSimpleName(), map.get("nr"));
                            list.remove(map);
                            break;
                        }
                    }
                    sb.append("</td>");
                }
                sb.append("</tr>");
            }
            return sb.toString();
        } catch (Exception e) {
            error("<<{}>> getZhy error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> getZhy end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 周会议
     *
     * @return 周会议html代码
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_getJskb, method = RequestMethod.GET)
    @ResponseBody
    public String getJskb(HttpServletRequest request) {
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbutil = new DBMUtil("oa");

            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            /**
             * 查询OA数据库
             * t_zc表
             * zbh 周编号
             */
            String sql = "select zbh from t_zc where to_date(to_char(sysdate,'yyyyMMdd'),'yyyyMMdd') between ksrq and jsrq";
            BigDecimal obj = ((BigDecimal) dbutil.queryFieldValue(sql));
            String zbh = obj != null ? obj.toString() : null;
            if (zbh == null) {
//                throw new RuntimeException("教师课表无法获取周编号!");
            }

            /**
             *
             * 查询门户数据库遍历教师数据
             *
             * @参数 zc 周次， 教师名称
             */
            sql = "select zj,jc,jsqc,kc,zc,bj from T_JSKB where zc=? and jsmc=?";
            List<Map<String, Object>> list = dbutil.queryForList(null, sql, zbh, user.getUserloginid());
            StringBuffer sb = new StringBuffer();
            for (int i = 1; i <= 12; i++) {
                sb.append("<tr><td nowrap='nowrap'>" + "第" + i + "节" + "</td>");
                for (int j = 1; j <= 7; j++) {
                    sb.append("<td id='" + j + "_" + i + "'>");
                    for (Map<String, Object> map : list) {
                        if (j == Integer.parseInt(map.get("zj").toString()) && i == Integer.parseInt(map.get("jc").toString())) {
                            sb.append("<div titleDesc='" + map.get("bj") + "&nbsp;&nbsp;&nbsp;" + map.get("kc") + "'>●</div>");
                            break;
                        }
                    }
                    sb.append("</td>");
                }
                sb.append("</tr>");
            }
            debug("<<{}>> doView , stHtml : {}", this.getClass().getSimpleName(), sb.toString());// 计算方法执行时间
            return sb.toString();
        } catch (Exception e) {
            error("<<{}>> doView error : {}", this.getClass().getSimpleName(), e); // 日志
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> doView end : {}", this.getClass().getSimpleName(), timer.end());// 计算方法执行时间
        }
    }

    /**
     * 警院新闻界面
     *
     * @return 警院新闻界面
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_news, method = RequestMethod.GET)
    public String news(ModelMap map) {
        debug("<<{}>> news start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbmUtil = new DBMUtil("oa");
            List<Lbxx> news = getTzgg(dbmUtil, "1", null);
            map.put("news", news);
            int newsys = news.size() % 13 == 0 ? news.size() / 13 : (news.size() / 13 + 1);
            newsys = newsys == 0 ? 1 : newsys;
            map.put("newsys", newsys);
            return ActionConstant.MhQh.Forward_news;
        } catch (Exception e) {
            error("<<{}>> news error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> news end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 院内通报界面
     *
     * @return 院内通报界面
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_notice, method = RequestMethod.GET)
    public String notice(ModelMap map) {
        debug("<<{}>> notice start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbmUtil = new DBMUtil("oa");
            //院内通报
            List<Lbxx> yntb = getTzgg(dbmUtil, null,
                    "select topic as title,tbrq as time,tybsf as id" +
                            " from oa_t_yntb where tblx=1 and zt=3 order by tbrq desc");
            map.put("yntb", yntb);
            int yntbys = yntb.size() % 13 == 0 ? yntb.size() / 13 : (yntb.size() / 13 + 1);
            yntbys = yntbys == 0 ? 1 : yntbys;
            map.put("yntbys", yntbys); //院内通报页数
            //督学通报
            map.put("dxtb", getTzgg(dbmUtil, null,
                    "select topic as title,tbrq as time,tybsf as id" +
                            " from oa_t_yntb where tblx=2 and zt=3 order by tbrq desc"));
            //学生处通报
            map.put("xsctb", getTzgg(dbmUtil, null,
                    "select topic as title,tbrq as time,tybsf as id" +
                            " from oa_t_yntb where tblx=3 and zt=3 order by tbrq desc"));
            //教务通报
            map.put("jwtb", getTzgg(dbmUtil, null,
                    "select topic as title,tbrq as time,tybsf as id" +
                            " from oa_t_yntb where tblx=4 and zt=3 order by tbrq desc"));
            //纪委通报
            map.put("jwtb", getTzgg(dbmUtil, null,
                    "select topic as title,tbrq as time,tybsf as id" +
                            " from oa_t_yntb where tblx=5 and zt=3 order by tbrq desc"));
            return ActionConstant.MhQh.Forward_notice;
        } catch (Exception e) {
            error("<<{}>> notice error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> notice end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 院内新闻界面
     *
     * @return 院内新闻界面
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_rule, method = RequestMethod.GET)
    public String rule(ModelMap map) {
        debug("<<{}>> rule start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbmUtil = new DBMUtil("oa");
            //党群工作
            List<Lbxx> dqgz = getTzgg(dbmUtil, "9", null);
            map.put("dqgz", dqgz);
            int dqgzys = dqgz.size() % 13 == 0 ? dqgz.size() / 13 : (dqgz.size() / 13 + 1);
            dqgzys = dqgzys == 0 ? 1 : dqgzys;
            map.put("dqgzys", dqgzys); //党群工作页数
            map.put("xzgz", getTzgg(dbmUtil, "10", null)); //行政工作
            map.put("jyxlgz", getTzgg(dbmUtil, "11", null)); //教育训练工作
            map.put("gjzcfg", getTzgg(dbmUtil, "12", null)); //国家政策法规
            return ActionConstant.MhQh.Forward_rule;
        } catch (Exception e) {
            error("<<{}>> rule error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> rule end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 部门动态界面
     *
     * @return 部门动态界面
     */
    @RequestMapping(value = ActionConstant.MhQh.RequestMapping_depart, method = RequestMethod.GET)
    public String depart(ModelMap map) {
        debug("<<{}>> news start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbmUtil = new DBMUtil("oa");
            List<Lbxx> depart = getTzgg(dbmUtil, null,
                    "select nvl(topic,' ') as title,nvl(b.name,' ') as depart,tbrq  as time,tybsf as id" +
                            " from OA_BMJB a left join lborganization b on a.tbbm=b.id" +
                            " left join tuser c on c.id=a.tbr where a.zt=3 order by tbrq desc,a.id desc");
            map.put("depart", depart);
            int departys = depart.size() % 13 == 0 ? depart.size() / 13 : (depart.size() / 13 + 1);
            departys = departys == 0 ? 1 : departys;
            map.put("departys", departys);
            return ActionConstant.MhQh.Forward_depart;
        } catch (Exception e) {
            error("<<{}>> news error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> news end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }
}